package com.veer.shop.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.veer.shop.annotation.ApiControllerLog;
import com.veer.shop.annotation.ApiSecured;
import com.veer.shop.config.ApiUrlConfig;
import com.veer.shop.pojo.ProductCategory;
import com.veer.shop.pojo.ResponseData;
import com.veer.shop.service.impl.admin.CategoryServiceImpl;

/**
 * 商品分类  控制器
 * 
 * @author WangBin
 * 2020年9月151日-下午5:52:04
 */
@RestController
public class CategoryController {
	
	@Autowired
	private CategoryServiceImpl adminProductCategoryServiceImpl;
	
	/**
	 * 获取后台商品分类列表
	 */
	@ApiSecured
	@ApiControllerLog(description = "获取分类列表")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_CATEGORY_LIST_URL, method = RequestMethod.GET)
	public ResponseData<?> getList()
	{
		return adminProductCategoryServiceImpl.getAll();
	}
	
	/**
	 * 新增|更新后台商品分类
	 */
	@ApiSecured
	@ApiControllerLog(description = "新增|更新后台商品分类")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_CATEGORY_UPDATE_URL, method = RequestMethod.POST)
	public ResponseData<?> update(@RequestBody ProductCategory category)
	{
		return adminProductCategoryServiceImpl.update(category);
	}
	
	/**
	 * 删除后台商品分类
	 */
	@ApiSecured
	@ApiControllerLog(description = "删除后台商品分类")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_CATEGORY_DELETE_URL, method = RequestMethod.POST)
	public ResponseData<?> delete(@RequestParam(name = "category_id", defaultValue = "") String category_id)
	{
		return adminProductCategoryServiceImpl.delete(category_id);
	}
	
	/**
	 * 后台商品分类详情
	 */
	@ApiSecured
	@ApiControllerLog(description = "后台商品分类详情")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_CATEGORY_GET_URL, method = RequestMethod.GET)
	public ResponseData<?> get(@RequestParam(name = "category_id", defaultValue = "") int category_id)
	{
		return adminProductCategoryServiceImpl.get(category_id);
	}
}
